package com.haitaoit.chengquan.module.car.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.LinearLayout;

import com.haitaoit.chengquan.R;
import com.haitaoit.chengquan.base.BaseActivity;
import com.haitaoit.chengquan.module.car.adapter.CouponAdapter;
import com.haitaoit.chengquan.module.center.model.MyCouponModel2;
import com.haitaoit.chengquan.utils.ToastUtils;
import com.haitaoit.chengquan.view.MyListView;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;

import java.util.List;

public class CouponActivity extends BaseActivity {
    @ViewInject(R.id.null_information_layout)
    LinearLayout null_information_layout;
    @ViewInject(R.id.scrollview_listview)
    MyListView listView;


    private CouponAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView_V(R.layout.activity_coupon);
        setTitle_V("选择优惠券");
        setLeftShow(1, R.mipmap.left);
        backLeft_V();
        ViewUtils.inject(this);


        List<MyCouponModel2> list = (List<MyCouponModel2>) getIntent().getSerializableExtra("coupon");
        if (list.size() == 0) {
            null_information_layout.setVisibility(View.VISIBLE);
            listView.setVisibility(View.GONE);
        } else {
            adapter = new CouponAdapter(this);
            adapter.setList(list);
            listView.setAdapter(adapter);
        }

        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent i = new Intent();
                i.putExtra("position", position + "");
                setResult(11, i);
                finish();
            }
        });
    }
}
